package com.gec.dao.Impl;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;
import com.gec.dao.ShopDao;
import com.gec.entity.Shop;

public class ShopDaoImpl extends BaseDaoImpl<Shop> implements ShopDao {

	@Override
	public void insert(Shop a) {
		
	}

	@Override
	public int update(Shop a) {
		return 0;
	}

	@Override
	public int delete(Integer id) {
		return 0;
	}

	@Override
	public Shop selectById(Integer id) {
		return null;
	}

	@Override
	public List<Shop> selectAll() {
		return null;
	}

	@Override
	protected Shop mapper(ResultSet rs) throws SQLException {
		Shop s = new Shop();
		s.setId(rs.getInt(1));	
		s.setName(rs.getString(2));
		s.setImg(rs.getString(3));
		s.setDepict(rs.getString(4));
		s.setTel(rs.getString(5));
		s.setLoginName(rs.getString(6));
		s.setLoginPwd(rs.getString(7));
		s.setWorktime(rs.getString(8));
		s.setWorkstate(rs.getInt(9));
		s.setStartMoney(rs.getFloat(10));
		s.setScore(rs.getInt(11));
		s.setRegtime(rs.getDate(12));
		s.setSalacount(rs.getFloat(13));
		return s;
	}

	@Override
	public List<Shop> selectPage(int page, int row) {
		String sql = "select * from fs_shop limit ?,?";
		return this.execQuery(sql, (page-1)*row,row);
	}

	@Override
	public long selectCount() {
		return (long) this.execSingle("select count(1) from fs_shop");
	}

	@Override
	public List<Shop> selectPageByName(String name, int page, int row) {
		String sql = "select * from fs_shop where shop_name like ? limit ?,?";
		return this.execQuery(sql,name, (page-1)*row,row);
	}

	@Override
	public long selectCount(String name) {
		return (long) this.execSingle("select count(1) from fs_shop where shop_name like ?", name);
	}

	@Override
	public Shop selectShopId(int shopid) {
		String sql = "select * from fs_shop where shop_id = ?";
		return execOne(sql, shopid);
	}

	@Override
	public Shop finAll(Integer id) {
		String sql = "select * from fs_shop where shop_id = ?";
		return this.execOne(sql, id);
	}

}
